<?php
defined('BASEPATH') OR exit('No direct script access allowed');
//教练
class Coach extends MY_Controller {
		
	function __construct(){
		parent::__construct();
		
		$this->load->model('Index/CoachModel', 'item');
	}	
	
	//start
	/**
	* @name 获取教练列表
	* @param page true int page
	* @param size true int size
	* @param keyword true char keyword
	* @return 
	*/
	//end
	public function get_list(){		
		$page		= $this->input->post('page');
		$size		= $this->input->post('size');
		$keyword	= $this->input->post('keyword');
		
		if($page<1)$page=1;
		if($size<1)$size=10;
		
		$arr = array(
			"keyword" => $keyword
		);
		
		$res = $this->item->get_list($arr,$page,$size);
		
		if(($page-1)*$size>$res['count']){
			$this->err_out('没有了',10);
		}
	
		$data['result_code'] = 0;
		$data['message']     = '获取列表成功';
		$data['data'] = array('count'=>$res['count'],'list'=>$res['list']);
	
		$this->out($data);
	}
	
	//详细
	public function get_info(){		
		$id		= $this->input->post('id',null,'0');		
		$info = $this->item->get_info($id);
		if(!$info){
			$this->err_out('数据不存在');
		}
		
		$res = $this->item->get_info($id);
		
		$data['result_code'] = 0;
		$data['message']     = '成功';
		$data['data'] 		 = $res;
	
		$this->out($data);
	}
	
	//start
	/**
	* @name 获取所有教练
	* @return 
	*/
	//end
	public function get_lists(){
		$res = $this->item->get_lists();
		
		$data['result_code'] = 0;
		$data['message']     = '获取成功';
		$data['data'] 		 = $res;	
		$this->out($data);
	}
	
	
	
	
}
